import { defineEventHandler, getRouterParam } from 'h3';

export default defineEventHandler(async (event) => {
  const applicationId = getRouterParam(event, 'applicationId');

  // 模拟应用配置数据
  const config = {
    applicationId,
    basic: {
      name: '智慧酒店管理系统',
      version: '1.2.0',
      description: '基于SaaS的酒店管理解决方案',
      environment: 'prod',
      region: 'cn-hangzhou',
    },
    resources: {
      cpu: 4,
      memory: 8,
      storage: 100,
      domain: 'hotel.example.com',
      port: 80,
      replicas: 2,
      autoScale: true,
    },
    envVars: [
      { id: 1, key: 'NODE_ENV', value: 'production', description: '运行环境' },
      {
        id: 2,
        key: 'DB_HOST',
        value: 'mysql.example.com',
        description: '数据库主机',
      },
      {
        id: 3,
        key: 'REDIS_HOST',
        value: 'redis.example.com',
        description: 'Redis主机',
      },
      { id: 4, key: 'API_KEY', value: '******', description: 'API密钥' },
    ],
    features: [
      { key: 'auth', name: '用户认证', enabled: true, required: true },
      { key: 'payment', name: '支付功能', enabled: true, required: false },
      { key: 'notification', name: '消息通知', enabled: true, required: false },
      { key: 'analytics', name: '数据分析', enabled: false, required: false },
      { key: 'backup', name: '数据备份', enabled: true, required: false },
      { key: 'monitoring', name: '系统监控', enabled: true, required: false },
    ],
    advancedFeatures: [
      { key: 'ssl', name: 'SSL证书', enabled: true },
      { key: 'cdn', name: 'CDN加速', enabled: false },
      { key: 'loadbalancer', name: '负载均衡', enabled: true },
      { key: 'autoscaling', name: '自动扩缩容', enabled: true },
      { key: 'backup', name: '自动备份', enabled: true },
      { key: 'logging', name: '日志收集', enabled: true },
    ],
  };

  return {
    code: 0,
    data: config,
    msg: '获取应用配置成功',
  };
});
